if __name__ == "__main__":
    n = eval(input(""))

    with open("hamlet.txt", "r", encoding='utf-8') as f:
        except_char = '!"#$%&()*+,-./:;<=>?@[\\]^_‘{|}~\n'
        content = []
        all_content = ""
        words_dict = {}

        for item in f.read():
            for i in except_char:
                item = item.replace(i, " ")
            all_content += item.lower()

        content += all_content.split(" ")

        for item in content:
            if item != "":
                words_dict[item] = words_dict.get(item, 0) + 1

        words_list = list(words_dict.items())
        words_list.sort(key=lambda x: x[1], reverse=True)

        for i in range(n):
            word, count = words_list[i]
            print(f"{word:<9} {count:>5}")
